<template>

  <div class="app-container">

    <!-- <div class="dashboard-editor-container" style="width: 80%;margin: 0 auto">-->
    <el-row>
      <el-col>
        <el-card class="box-card">

          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="48px" style="margin-top: 10px">
            <el-form-item label="标题" prop="noticeTitle" >
              <el-input
                v-model="queryParams.noticeTitle"
                placeholder="请输入训练计划标题"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>

            <el-form-item label="栏目" prop="contentColumn">
              <el-select
                v-model="queryParams.contentColumn"
                placeholder="请选择栏目"
                clearable
              >
                <el-option
                  v-for="dict in dict.type.junshi"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>


            <br/>
            <div style="text-align:right;">

              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

            </div>
            <br/>

          </el-form>
          <el-table v-loading="loading" :data="contentList"  border @selection-change="handleSelectionChange">
            <el-table-column type="index" label="序号"   :index="indexMethod" align="center"/>
            <el-table-column label="训练计划" align="center" prop="noticeTitle">
              <template slot-scope="scope">
                <div @click="getLista(scope.row)" v-hasPermi="['lys:policy:list']" style="cursor: pointer;">
                  {{scope.row.noticeTitle}}
                </div>
              </template>

            </el-table-column>
            <el-table-column
              label="创建时间"
              prop="createTime"

              align="center"
              width="200px">
            </el-table-column>
          </el-table>

          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-card>
      </el-col>
    </el-row>
  </div>
  <!--</div>-->
</template>
<script>
import {listContent } from "@/api/module/yzx/tp/trainingplan";
import watermark from "watermark-dom";

export default {
  dicts:['yh_notice_status','junshi'],
  name: "Content",
  mounted() {
    watermark.load({ watermark_txt: '  '   });
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 内容公告发布表格数据
      contentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        noticeType: '9',
        noticeTitle: null,
        noticeContent: null,
        noticeStatus:'1',
        pictureUrl: null,
        sourcesUrl: null,
        releaseTime: null,
        participants: null,
        viewsTimes: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询内容公告发布列表 */
    getList() {
      this.loading = true;
      listContent(this.queryParams).then(response => {
        this.contentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index
    },
    /** 详情操作 */
    getLista(row) {
      const id = row.id;
      // const tableName = row.tableName || this.tableNames[0];
      const params = {pageNum: this.queryParams.pageNum};
      const title = row.noticeTitle;
      this.$router.push({path: "/yewu/yzxxljhxiangqing", query: {id}});
      getContent(id).then(response => {
        this.form = response.data;
        this.form.viewsTimes=parseInt(this.form.viewsTimes) + 1;
        updateContent(this.form).then(response => {
        });
      });
    },
  },
};
</script>
